//
//  PasswordStepController.m
//  WuJieLive
//
//  Created by 张瀚坤 on 2017/10/30.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "PasswordStepController.h"
#import "IdentityStepController.h"
#import "ForgetPasswordViewController.h"

@interface PasswordStepController ()
@property (weak, nonatomic) IBOutlet UITextField *passwordText;
@property (weak, nonatomic) IBOutlet UIButton *nextBtn;

@end

@implementation PasswordStepController

- (void)viewDidLoad {
    [super viewDidLoad];
}

-(void)setNavi
{
    self.title = @"修改支付密码";
}

-(void)setUI
{
    self.view.backgroundColor =  Color(245, 245, 245);
    [self.passwordText addTarget:self action:@selector(textFieldDidChange:) forControlEvents:(UIControlEventEditingChanged)];
}

- (void)textFieldDidChange:(UITextField *)textField
{
    if (self.passwordText.text.length >= 6) {
        self.nextBtn.userInteractionEnabled = YES;
        [self.nextBtn setBackgroundColor:MainColor];
    }else
    {
        [self.nextBtn setBackgroundColor:MainBtnColor];
        self.nextBtn.userInteractionEnabled = NO;
    }
}

- (void)canSee:(UIButton *)sender
{
    sender.selected = !sender.isSelected;
    self.passwordText.secureTextEntry = !sender.selected;
}

- (IBAction)nextAction:(id)sender {
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    NSDictionary * dict = @{@"token":self.userToken,@"old_password":self.passwordText.text};
    [HTTPTool POSTForm:[NSString stringWithFormat:@"%@deposit-account/check-id-payment-password",BaseUrl] para:dict success:^(BOOL isSuccess, id responseObject) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        if (isSuccess) {
            IdentityStepController * vc = [[IdentityStepController alloc]init];
            vc.labelText = @"验证登录密码";
            [self.navigationController pushViewController:vc animated:YES];
        }
    } failure:^(NSError *error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    }];
}
- (IBAction)safeAction:(UIButton *)sender {
    
    sender.selected = !sender.isSelected;
    self.passwordText.secureTextEntry = !sender.isSelected;
}
- (IBAction)forgetPasswordAction:(id)sender {
    
    ForgetPasswordViewController * vc = [[ForgetPasswordViewController alloc]initWithNibName:@"ForgetPasswordViewController" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:vc animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
